﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ClassDAL;
using ClassCommon;
using ClassModel;

namespace ClassBLL
{
    public class t_class_teacher_BLL
    {
        /// <summary>
        /// 批量插入
        /// </summary>
        /// <param name="teachers"></param>
        /// <returns></returns>
        public static int InsertTeachers(IList<t_class_tearcher> teachers)
        {
            if (teachers == null) throw new ArgumentException("teachers is null");

            return t_class_teacher_DAL.InsertTeachers(teachers);
        }


        /// <summary>
        /// 获取某个excel文件里的老师信息(根据fileid)
        /// </summary>
        /// <param name="fileid">文件id</param>
        /// <returns></returns>
        public static List<t_class_tearcher> GetTeacherListWithFileId(int fileid)
        {
            return t_class_teacher_DAL.GetTeacherListWithFileId(fileid);
        }


        /// <summary>
        /// 获取老师的信息，用于不排课条件的限制页面的数据绑定
        /// </summary>
        /// <param name="fileid"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageCount"></param>
        public static List<t_class_teacherBind_Info> GetTeachersInfoWhitFileId(
            int fileid,
            out int totalCount,
            int pageIndex = 0,
            int pageCount = 10
            )
        {
            var list = t_class_teacher_DAL.GetTeachersInfoWhitFileId(fileid, out totalCount, pageIndex);

            // 获取老师的上课节次数
            list.ForEach(info => {
                int classesCount = t_class_schedule_BLL.GetTeacherClassesCount(info.tid);
                info.classesCount = classesCount;
            });

            return list;
        }


         /// <summary>
        /// 获取老师信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static t_class_tearcher GetTeacherInfoById(int id)
        {
            return t_class_teacher_DAL.GetTeacherInfoById(id);
        }


         /// <summary>
        /// 根据fileid获取老师的数量
        /// </summary>
        /// <param name="fileid"></param>
        /// <returns></returns>
        public static int GetTeacherCountWithField(int fileid)
        {
            return t_class_teacher_BLL.GetTeacherCountWithField(fileid);
        }
    }
}
